<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property int $user_id 
 * @property int $is_admin 
 * @property int $album_id 
 * @property string $file_name 
 * @property string $extension 
 * @property string $path 
 * @property int $size 
 * @property string $mime 
 * @property int $is_image 
 * @property int $fileable_id 
 * @property string $fileable_type 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property string $deleted_at 
 */
class File extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'files';

    protected $appends=['url'];
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id',
        'is_admin',
        'album_id',
        'file_name',
        'extension',
        'path',
        'size',
        'mime',
        'is_image'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'int', 'user_id' => 'integer', 'is_admin' => 'integer', 'album_id' => 'integer', 'size' => 'integer', 'is_image' => 'integer', 'fileable_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getUrlAttribute()
    {
        return config('common.image_prefix').$this->path;
    }
}